const TEXT = 0
const TEXT_AREA = 1
const MOBILE_PHONE = 2
const LAND_LINE = 3
const EMAIL = 4
const NUMBER = 5
const CERTIFICATES = 6
const AMOUNT = 7
const RADIO = 8
const CHECK_BOX = 9
const SELECT = 10
const PERSONNEL = 11
const PEOPLE = 12
const ATTACHMENT = 13
const DATE = 14
const TIME = 15
const DATE_TIME = 16
const DATE_SPAN = 17
const DATE_TIME_SPAN = 18
const DISTRICT1 = 19
const FORMULA = 20
const RELATION = 21
const SPLIT_LINE = 22
const DISTRICT2 = 23
const DISTRICT3 = 24
const BIG_AMOUNT = 25
const USER_SELECT = 26
const DEPARTMENT_SELECT = 27
const SCORE = 28
const RELATION_WORKSHEET = 29
const RELATION_WS_COLUMN = 30
const WS_FORMULA = 31
const FORMULA_STRING = 32
const INCREASE = 33
const DETAIL_TABLE = 34
const CASCADE = 35
const CHECK_RADIO = 36
const SUMMARY = 37
const FORMULA_DATE = 38
const SCAN_CODE = 39
const LOCATION = 40
const RICH_TEXT = 41
const SIGNATURE = 42
const RATE = 43
const SLIDER = 44
const UPLOAD_FILE = 45
const UPLOAD_IMG = 46
const TREE_SELECT = 47
const BATCH = 48
const SWITCH = 49
const BUTTON = 50
const ALERT = 51
const TEXT_FONT = 52
const HTML = 53

class DataType {
  constructor (idx, name, desc, example) {
    this.idx = idx
    this.name = name
    this.desc = desc
    this.example = example
    if (example) {
      this.example = example
    } else {
      switch (desc) {
        case 'string':
          this.example = '文本'
          break
        case 'number':
          this.example = 123.45
      }

      switch (idx) {
        case UPLOAD_IMG:
          this.example = [
            {
              name: '图片名称(选填)',
              url: '图片路径',
            }
          ]
      }
    }
  }

  static getName (idx) {
    return DataType[idx] && DataType[idx].name
  }

  static getDesc (idx) {
    return DataType[idx] && DataType[idx].desc
  }

  static getExample (idx) {
    return DataType[idx] && DataType[idx].example
  }
}

DataType[TEXT] = new DataType(TEXT, '文本框', 'string')
DataType[TEXT_AREA] = new DataType(TEXT_AREA, '多行文本框', 'string')
DataType[MOBILE_PHONE] = new DataType(MOBILE_PHONE, '手机', 'number')
DataType[LAND_LINE] = new DataType(LAND_LINE, '座机', 'number')
DataType[EMAIL] = new DataType(EMAIL, '邮箱', 'string')
DataType[NUMBER] = new DataType(NUMBER, '数值', 'number')
DataType[CERTIFICATES] = new DataType(CERTIFICATES, '证件', 'string')
DataType[AMOUNT] = new DataType(AMOUNT, '数量', 'number')
DataType[RADIO] = new DataType(RADIO, '单选框', 'string')
DataType[CHECK_BOX] = new DataType(CHECK_BOX, '多选框', 'string')
DataType[SELECT] = new DataType(SELECT, '下拉框', 'string')
DataType[PERSONNEL] = new DataType(PERSONNEL, '单成员', 'string')
DataType[PEOPLE] = new DataType(PEOPLE, '多成员', 'string')
DataType[ATTACHMENT] = new DataType(ATTACHMENT, '附件', 'string')
DataType[DATE] = new DataType(DATE, '日期', 'string', '2006-01-02 15:04:05')
DataType[TIME] = new DataType(DATE, '时间', 'string', '15:04:05')
DataType[DATE_TIME] = new DataType(DATE_TIME, '日期和时间', 'string', '2006-01-02 15:04:05')
DataType[DATE_SPAN] = new DataType(DATE_SPAN, '日期段', 'string')
DataType[DATE_TIME_SPAN] = new DataType(DATE_TIME_SPAN, '日期时间段', 'string')
DataType[DISTRICT1] = new DataType(DISTRICT1, '地区（省）', 'string')
DataType[FORMULA] = new DataType(FORMULA, '公式', 'string')
DataType[RELATION] = new DataType(RELATION, '自由连接', 'string')
DataType[SPLIT_LINE] = new DataType(SPLIT_LINE, '分段', 'string')
DataType[DISTRICT2] = new DataType(DISTRICT2, '地区（省-市）', 'string')
DataType[DISTRICT3] = new DataType(DISTRICT3, '地区（省-市-县）', 'string')
DataType[BIG_AMOUNT] = new DataType(BIG_AMOUNT, '大写金额', 'string')
DataType[USER_SELECT] = new DataType(USER_SELECT, '人员', 'string')
DataType[DEPARTMENT_SELECT] = new DataType(DEPARTMENT_SELECT, '部门', 'string')
DataType[SCORE] = new DataType(SCORE, '等级', 'string')
DataType[RELATION_WORKSHEET] = new DataType(RELATION_WORKSHEET, '表关联', 'string')
DataType[RELATION_WS_COLUMN] = new DataType(RELATION_WS_COLUMN, '关联表字段', 'string')
DataType[WS_FORMULA] = new DataType(WS_FORMULA, '工作表公式', 'string')
DataType[FORMULA_STRING] = new DataType(FORMULA_STRING, '文本拼接', 'string')
DataType[INCREASE] = new DataType(INCREASE, '自动编号', 'string')
DataType[DETAIL_TABLE] = new DataType(DETAIL_TABLE, '子表', 'string')
DataType[CASCADE] = new DataType(CASCADE, '级联选择器', 'string')
DataType[CHECK_RADIO] = new DataType(CHECK_RADIO, '检查框', 'string')
DataType[SUMMARY] = new DataType(SUMMARY, '汇总', 'string')
DataType[FORMULA_DATE] = new DataType(FORMULA_DATE, '公式(日期)', 'string')
DataType[SCAN_CODE] = new DataType(SCAN_CODE, '扫码', 'string')
DataType[LOCATION] = new DataType(LOCATION, '定位', 'string')
DataType[RICH_TEXT] = new DataType(RICH_TEXT, '富文本', 'string')
DataType[SIGNATURE] = new DataType(SIGNATURE, '签名', 'string')
DataType[RATE] = new DataType(RATE, '评分', 'string')
DataType[SLIDER] = new DataType(SLIDER, '滑动输入条', 'string')
DataType[UPLOAD_FILE] = new DataType(UPLOAD_FILE, '文件', 'string')
DataType[UPLOAD_IMG] = new DataType(UPLOAD_IMG, '图片', 'array')
DataType[TREE_SELECT] = new DataType(TREE_SELECT, '树选择器', 'string')
DataType[BATCH] = new DataType(BATCH, '动态表格', 'string')
DataType[SWITCH] = new DataType(SWITCH, '开关', 'string')
DataType[BUTTON] = new DataType(BUTTON, '按钮', 'string')
DataType[ALERT] = new DataType(ALERT, '警告提示', 'string')
DataType[TEXT_FONT] = new DataType(TEXT_FONT, '文字', 'string')
DataType[HTML] = new DataType(HTML, 'html', 'string')

export { DataType }
